<template>
  <Layout>
    <div class="project" data-v-7f3c42a8="">
      <div class="container" data-v-7f3c42a8="">
        <div class="project-header" data-v-7f3c42a8="">
          <h1 class="project-title" data-v-7f3c42a8="">{{project.title}}</h1>
          <div class="project-info" data-v-7f3c42a8="">
            <div class="categories-container" data-v-7f3c42a8="">
              <div class="categories" data-v-7f3c42a8="">
                <span class="label" data-v-7f3c42a8="">Categories</span>
                <span class="category" v-for="category in project.categories" :key="category.id" data-v-7f3c42a8="">{{category.title}}</span>
              </div>
            </div>
            <div class="year-container" data-v-7f3c42a8="">
              <span class="label" data-v-7f3c42a8="">Year</span>
              <div data-v-7f3c42a8="">{{project.created_at}}</div>
            </div>
          </div>
        </div>
        <div class="content" data-v-7f3c42a8="" v-html="mdToHtml(project.content)">
         
        </div>
      </div>
    </div>
  </Layout>
</template>
<page-query>
query($name: String) {
  project:allStrapiProject(filter:{name: {eq:$name}}) {
    edges{
      node{
        id
        title
        name
        color
        bgcolor
        categories{
          id
          title
        }
        created_at(format: "Y")
        cover{
          url
        }
        content
      }
    }
  }
}
</page-query>
<script>
import MarkdownIt from 'markdown-it'
const md = new MarkdownIt()
export default {
  name: 'ProjectPostPage',
  metaInfo(){
    return {
      title: 'ProjectPage',
      bodyAttrs: {
        style: `background-color: ${this.project.bgcolor}; color: ${this.project.color}`
      }
    }
  },
  computed: {
    project(){
      return this.$page.project.edges[0].node
    }
  },
  methods: {
    mdToHtml(markdown) {
      return markdown && md.render(markdown).replace('/uploads', process.env.GRIDSOME_STRAPI_URL + '/uploads') || ''
    }
  }
  
}
</script>

<style>

</style>